<template>
	<view v-if="pageShow" class="mainpadding2">
		<view class="mainpadding_top radius" style="background-color: #fbf6f1;" v-for="item in list" :key="item.id">
			<view class="flexleft ">
				<view class="margin_right2">
					<view class="huang_text titletext bold">${{item.dk_money}}</view>
					<view class="hui_text main_size margin_top bold">滿{{item.di_money}}可用</view>
				</view>
				<view class="line margin_right2"></view>
				<view>
					<view class="hei_text titletext bold">{{item.name}}</view>
					<view class="margin_top hui_text main_size bold">有效期至{{http.returnDate(item.endtime*1000)}}</view>
				</view>
			</view>
		</view>
		<view class="posibottom mainpadding">
			<view class="submitbtn" @click="submit">確認核銷</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				rall_ids:"",
				listids:"",
				pageShow:false,
				list:[],
				paraString:"",
			}
		},
		onLoad(options) {
			this.paraString = window.location.href //还可以  window.location.search.substring()
			this.listids = this.getQueryVariable('ids') //code是url後面带的
			this.rall_ids = this.getQueryVariable('rall_ids') //code是url後面带的
			this.init()
		},
		methods: {
			getQueryVariable(variable) {
				var query = this.paraString;
				var rooms = query.split('?');
				for (var i = 0; i < rooms.length; i++) {
					var pair = rooms[i].split('=');
					if (pair[0] == variable) {
						return (pair[1].split('&'))[0]
					}
				}
				//或者拼接&後面的值
				var vars = query.split('&')
				for (var i = 0; i < vars.length; i++) {
					var pair = vars[i].split('=')
					if (pair[0] == variable) {
						return pair[1]
					}
				}
			},
			init(){
				this.http.request("/api/shop/rallAlldeail", 'POST', {
					id: this.listids,
				}).then(res=>{
					this.list = res.data
					this.pageShow = true
				})
			},
			submit(){
				this.http.request("/api/shop/hxyjh", 'POST', {
					id: this.listids,
					shop_id: uni.getStorageSync("shop_id"),
				}).then(res=>{
					this.http.toast(res.msg)
					if(res.code==1){
						setTimeout(()=>{
							uni.switchTab({
								url:"/pages/workbench/workbench"
							})
						},1000)
					}
				})
			}
		}
	}
</script>

<style lang="scss" scoped>
	.line {
		width: 2rpx;
		height: 50rpx;
		background-color: #999;
	}
</style>
